#!/bin/bash

test -e bin/wget && exit

echo "####################"
echo "# $ZLIB"
echo "####################"

export ZLIB_BUILD_DIR=$DIR/$ZLIB/build

cd $DIR
test ! -e $ZLIB.tar.gz && wget http://www.zlib.net/$ZLIB.tar.gz
tar xzvf $ZLIB.tar.gz
cd $ZLIB
./configure --prefix=$ZLIB_BUILD_DIR
make clean
make
make install

echo "####################"
echo "# $WGET"
echo "####################"

cd $DIR
test ! -e $WGET.tar.gz && wget http://ftp.gnu.org/gnu/wget/$WGET.tar.gz
tar xzvf $WGET.tar.gz
cd $WGET

export LDFLAGS=-static
test "$TARGET_HOST" && ./configure --host=$TARGET_HOST --with-zlib=$ZLIB_BUILD_DIR --enable-static --disable-shared --without-ssl
test -z "$TARGET_HOST" && ./configure --with-zlib=$ZLIB_BUILD_DIR  --enable-static --disable-shared --without-ssl

export LDFLAGS=-static
make clean
make

test "$STRIP" && $STRIP src/wget
test -z "$STRIP" && strip src/wget
